package clases;

import CiaoJava.*;

//import ciao.CiaoExecutor ;
//import CIaoJava.*;
public class MainPL{

   private static PLConnection plServer = null;


       public static void main(String[] args0) {
               System.out.println("Start...");
               try {
//                       String argv []= {"i:\\prog\\ciao-1.10p5Win32\\Win32\\bin\\ciaoengine.exe", "-C", "-b", "i:\\prog\\ciao-1.10p5Win32\\library\\javall\\plserver.cpx "};
                   plServer = new PLConnection();
               } catch (Exception e) {
                   System.err.println("Problems starting java server: " + e);
                   e.printStackTrace();
                   System.exit(1);
               }

               PLVariable currentSolution = new PLVariable();

               PLTerm t = new PLStructure("pred",new PLTerm[] {currentSolution});
               //PLTerm t = new PLStructure("is",new PLTerm[] {currentSolution, new PLInteger(2)});

               PLGoal goal = new PLGoal(plServer,t);

               try {
                       goal.useModule("mymodul1");
                       goal.query();

                       while (goal.nextSolution() != null)
                   System.out.println("Solution for: " + t + " is "+ currentSolution.getBinding());

                   System.out.println("There are no more solutions");
               } catch (Exception e) {
                   System.err.println("Problems launching goal: " + e);
                   System.exit(1);
               }

               try {
                   plServer.stop();
                   System.exit(0);
               } catch (Exception e) {
                   System.err.println("Problems stopping Prolog server: " + e);
                   System.exit(1);
               }
       }
}